//
// Created by gyc on 2020/11/2.
//

#include "../../common.h"

class Solution {
public:
    vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {

        vector<int> res{};
        unordered_set<int> set1{};

        for(int i: nums1) {
            set1.emplace(i);
        }

        for(int i: nums2) {
            if (set1.count(i)) {
                set1.erase(i);
                res.emplace_back(i);
            }
        }
        return res;
    }
};